import com.alibaba.nacos.api.naming.NamingFactory;
import com.alibaba.nacos.api.naming.NamingService;
import com.alibaba.nacos.api.naming.pojo.Instance;

import java.util.List;
import java.util.Properties;

/**
 * 服务发现
 */
public class TestNacosAPI2 {
    public static void main(String[] args) throws Exception{
        String serverAddr = "127.0.0.1";
        Properties properties = new Properties();
        properties.put("serverAddr", serverAddr);
        NamingService namingService = NamingFactory.createNamingService(properties);

        // 获取所有的userService服务
        List<Instance> list = namingService.getAllInstances("userService");
        list.forEach(System.out::println);
    }
}
